<template>
	<view class="container">
		<view class="item" v-for="(item, index) in list" :key="index">
			<image class="item-image" :src="item.image"></image>
			<view class="item-1">
				<text class="item-text">{{ item.text }}</text>
				<br />
				<text class="item-teacher">{{ item.teacher }}</text>
				<view class=" item-price">
					<text class="item-details" @click="handleClick(item)">{{ item.details}}</text>
					<text class="item-jiage">{{ item.price}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						id: 1,
						image: '/static/image/软件技术.png',
						text: 'MySQL基础入门–mysql数据库实战教程',
						teacher: '李老师',
						details: '查看详情',
						price: '￥250.00'
					},
					{
						id: 2,
						image: '/static/image/python.png',
						text: '专升本高等数学微积分课程学习',
						teacher: '罗老师',
						details: '查看详情',
						price: '￥120.00'
					},
					{
						id: 3,
						image: '/static/image/c语言.png',
						text: 'MySQL基础入门–mysql数据库实战教程',
						teacher: '郭老师',
						details: '查看详情',
						price: '￥400.00'
					},
					{
						id: 4,
						image: '/static/image/uniapp.png',
						text: 'MySQL基础入门–mysql数据库实战教程',
						teacher: '刘老师',
						details: '查看详情',
						price: '￥360.00'
					},
					{
						id: 5,
						image: '/static/image/mysql.png',
						text: 'MySQL基础入门–mysql数据库实战教程',
						teacher: '李老师',
						details: '查看详情',
						price: '￥220.00'
					},
					{
						id: 6,
						image: '/static/image/mysql.png',
						text: 'MySQL基础入门–mysql数据库实战教程',
						teacher: '李老师',
						details: '查看详情',
						price: '￥220.00'
					},
				],
			};
		},
		methods: {
			handleClick(item) {
				console.log('Clicked:', item);
				// 跳转到详情页，并传递参数
				uni.navigateTo({
					url: `/pages/course/course?title=${encodeURIComponent(item.text)}&teachers=${encodeURIComponent(item.teacher)}&price=${encodeURIComponent(item.price)}`
				});
			},
		},
	};
</script>

<style>
	.container {
		height: auto;
	}

	.item {
		display: flex;
		align-items: center;
		background-color: white;
		margin-top: 10rpx;
		margin-right: 10rpx;
		margin-left: 10rpx;
		width: 97%;
		height: 130px;
		border-radius: 2px;
	}

	.item-image {
		width: 150px;
		height: 110px;
		border-radius: 8px;
	}

	.item-1 {
		flex: 1;
		padding: 20px;
	}

	.item-text {
		font-size: 15px;
		font-weight: bold;
		color: #333;
	}

	.item-teacher {
		color: gray;
	}

	.item-price {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 10px;
	}

	.item-details {
		background-color: skyblue;
		border-radius: 5rpx;
		font-size: 14px;
		width: 70px;
		text-align: center;
	}

	.item-jiage {
		font-weight: bold;
		color: red;
	}
</style>